<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/tuzi32.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/tuzi16.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="git,实用网站," />





  <link rel="alternate" href="/atom.xml" title="ShaohuiのBlog" type="application/atom+xml" />






<meta name="description" content="声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。Github是什么？&amp;emsp;&amp;emsp;Github是一个代码托管平台，可以通过此平台找到许多开源项目，可以共享自己的开源项目与他人共同开发、完善，由于只支持Git的版本库格式进行托管，所以名为Github。 Git是什么？工作流程是什么？&amp;ems">
<meta name="keywords" content="git,实用网站">
<meta property="og:type" content="article">
<meta property="og:title" content="Github使用方法">
<meta property="og:url" content="https:&#x2F;&#x2F;huiboxs.cn&#x2F;2019&#x2F;12&#x2F;29&#x2F;githubTutorial&#x2F;index.html">
<meta property="og:site_name" content="ShaohuiのBlog">
<meta property="og:description" content="声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。Github是什么？&amp;emsp;&amp;emsp;Github是一个代码托管平台，可以通过此平台找到许多开源项目，可以共享自己的开源项目与他人共同开发、完善，由于只支持Git的版本库格式进行托管，所以名为Github。 Git是什么？工作流程是什么？&amp;ems">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https:&#x2F;&#x2F;huiboxs.cn&#x2F;2019&#x2F;12&#x2F;29&#x2F;githubTutorial&#x2F;gitadd.png">
<meta property="og:image" content="https:&#x2F;&#x2F;huiboxs.cn&#x2F;2019&#x2F;12&#x2F;29&#x2F;githubTutorial&#x2F;github.png">
<meta property="og:updated_time" content="2020-02-18T10:39:52.358Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https:&#x2F;&#x2F;huiboxs.cn&#x2F;2019&#x2F;12&#x2F;29&#x2F;githubTutorial&#x2F;gitadd.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://huiboxs.cn/2019/12/29/githubTutorial/"/>





  <title>Github使用方法 | ShaohuiのBlog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">ShaohuiのBlog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">编程初学者</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" target="_blank" rel="noopener" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://huiboxs.cn/2019/12/29/githubTutorial/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Shaohui">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/tx.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ShaohuiのBlog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Github使用方法</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-12-29T20:17:50+08:00">
                2019-12-29
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2019/12/29/githubTutorial/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2019/12/29/githubTutorial/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h4 id="声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。"><a href="#声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。" class="headerlink" title="声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。"></a><strong>声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。</strong></h4><h5 id="Github是什么？"><a href="#Github是什么？" class="headerlink" title="Github是什么？"></a>Github是什么？</h5><p>&emsp;&emsp;Github是一个代码托管平台，可以通过此平台找到许多开源项目，可以共享自己的开源项目与他人共同开发、完善，由于只支持Git的版本库格式进行托管，所以名为Github。</p>
<h5 id="Git是什么？工作流程是什么？"><a href="#Git是什么？工作流程是什么？" class="headerlink" title="Git是什么？工作流程是什么？"></a>Git是什么？工作流程是什么？</h5><p>&emsp;&emsp;Git是一个开源的分布式版本控制系统。了解工作流程首先要知道四个东西：</p>
<ul>
<li><p>Workspace：工作区</p>
</li>
<li><p>index/Stage：暂存区</p>
</li>
<li><p>Repository：仓库区</p>
</li>
<li><p>Remote：远程仓库</p>
<p>&emsp;&emsp;工作流程如下：在工作区中修改某些文件 → 对修改后的文件进行快照，然后保存到暂存区(add) → 提交更新，将保存在暂存区域的文件快照永久转储到Git目录中(仓库)(commit) → 将本地仓库push到远程仓库(push)</p>
</li>
</ul>
<h5 id="一、准备工作"><a href="#一、准备工作" class="headerlink" title="一、准备工作"></a>一、准备工作</h5><p>&emsp;&emsp;1.安装Git Bash：在 <a href="https://gitforwindows.org/" target="_blank" rel="noopener">https://gitforwindows.org/</a> 下载，然后一直下一步就好。</p>
<p>&emsp;&emsp;2.注册Github账户：点这里进入<a href="github.com">官网</a>,英语不好的建议用chrome，翻译挺好用的。注册时全部默认下一步即可，注册完账号就创建一个新仓库，别的都不管，直接默认的选项点下一步即可，等后面没事了一定要有空就打开看看，每个都按一下，摸索一下(不要删除仓库和账号就好)。</p>
<h5 id="二、配置Git-Bash："><a href="#二、配置Git-Bash：" class="headerlink" title="二、配置Git Bash："></a>二、配置Git Bash：</h5><p>&emsp;&emsp;在命令行依次在输入下面的内容，输一行，按一次回车。</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">git config --global user.name "huibox"				  #上传用户的称呼</span><br><span class="line">git config --global user.email "huiboxes@gmail.com"	  #上传用户的邮箱</span><br><span class="line">git config --global push.default simple				  #更改push方式</span><br><span class="line">git config --global core.quotepath false			  #防止文件名变成数字</span><br><span class="line">git config --global core.editor "vim"				  #使用vim编辑提交信息</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;在任何地方只需要右击鼠标，然后选Git Bash here即可打开一个命令行界面，默认情况打开后就处于当前文件所在位置。命令行内可以运行简单的Linux命令。</p>
<h5 id="三、配置Github"><a href="#三、配置Github" class="headerlink" title="三、配置Github"></a>三、配置Github</h5><h6 id="1、获取SSH公钥"><a href="#1、获取SSH公钥" class="headerlink" title="1、获取SSH公钥"></a>1、获取SSH公钥</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">rm -rf ~/.ssh/*										  #单击鼠标右键点击Git Bash here后输入</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;千万不能输错，不然就可能要重装系统了，回车后输入</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">ssh-keygen -t rsa -b 4096 -c "huiboxes@gmail.com"     #生成ssh key</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;按三次回车，得到ssh key。直接按，这个环节不会有任何错误。</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">cat ~/.ssh/id_rsa.pub 								  #屏幕上输出ssh公钥</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;将打印出的内容全部复制下来，在bash终端下复制快捷键为<code>ctrl+insert</code>。在根目录下的.ssh目录中有两个文件，id_rsa是私钥，不要给任何人。</p>
<h6 id="2、在Github添加公钥"><a href="#2、在Github添加公钥" class="headerlink" title="2、在Github添加公钥"></a>2、在Github添加公钥</h6><p>&emsp;&emsp;打开<a href="https://github.com/settings/keys" target="_blank" rel="noopener">https://github.com/settings/keys</a>  。点击<code>New SSH key</code>按钮，<code>title</code>随便输入什么，在<code>key</code>下的表单内粘贴刚刚复制的内容，点<code>Add SSH key</code>。</p>
<h6 id="3、测试是否已对接"><a href="#3、测试是否已对接" class="headerlink" title="3、测试是否已对接"></a>3、测试是否已对接</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">ssh -T git@github.com								   #打开Git Bash后输入</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;如果提示输入yes/no就输入yes，只要没有看到一串包含successfully的英文，就要重第一步重新弄。</p>
<ul>
<li>​    如果把key从电脑上删除了，重新生成一个就好了，替换之前的key。</li>
<li>​    一个电脑只需要一个key。</li>
<li>​    其他设备如果想的key上传到Github可以和之前的 key共存在Github上</li>
<li>​    一个key可以访问所有的仓库。</li>
</ul>
<h5 id="四、使用Git"><a href="#四、使用Git" class="headerlink" title="四、使用Git"></a>四、使用Git</h5><h6 id="1、本地仓库的使用-跟着敲会有奇效"><a href="#1、本地仓库的使用-跟着敲会有奇效" class="headerlink" title="1、本地仓库的使用(跟着敲会有奇效)"></a>1、本地仓库的使用(跟着敲会有奇效)</h6><p>&emsp;&emsp;在你认为合适的盘符下创建一个文件夹，进入该文件夹右击鼠标点Git Bash here。然后输入<code>git init</code><strong>初始化</strong>本地仓库，这个文件夹就成了工作区。使用命令行就简单多了，如下：</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">cd /f								#进入f盘（路径随意）</span><br><span class="line">mkdir fileName						#在当前目录创建名为"fileName"的文件夹（名字叫什么都可以）</span><br><span class="line">cd    fileName						#进入fileName目录</span><br><span class="line">git init							#初始化本地仓库</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;fileName文件夹内会多出一个名为<code>.git</code>的隐藏文件夹，对该文件夹下内容的任何改动都会被git记录，不要动这个隐藏文件。</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">touch test							#创建名为test的空文件=windows右键创建没有后缀名的文件</span><br><span class="line">git status -sb						#查看当前目录文件状态</span><br></pre></td></tr></table></figure>

<p>![](git status.png)</p>
<p>&emsp;&emsp;可以看到所创建的文件名前会有两个<code>??</code>。因为你还没有对该文件进行过git操作，git不知道你后面会怎样对待这些文件的变动（增加、删除、更改都是变动）。</p>
<p><img src="gitadd.png" alt=""></p>
<p>&emsp;&emsp;使用<code>git add 你创建的文件名</code>将某个文件<strong>添加</strong>到<strong>暂存区</strong>，使用<code>git add .</code>将当前目录里面所有的变动都加到暂存区。再次使用<code>git status -sb</code>会看到<code>??</code>变成了A(即Add添加)。</p>
<p>![](git commit.png)</p>
<p>&emsp;&emsp;使用<code>git commit 你创建的文件名 -m &quot;注释信息，方便以后查看&quot;</code>将某个文件<strong>提交</strong>到<strong>本地仓库</strong>，使用<code>git commit .  -m &quot;注释&quot;</code>将当前目录里文件都提交到本地仓库。这时再使用<code>git status -sb</code>会发现A变成了<code>M</code>(即Modified修改)。</p>
<h6 id="2、将本地仓库上传到Github"><a href="#2、将本地仓库上传到Github" class="headerlink" title="2、将本地仓库上传到Github"></a>2、将本地仓库上传到Github</h6><p>&emsp;&emsp;在文章开头就提到过在Github创建一个仓库，就是为了这一步。进入仓库首页复制你的仓库地址。</p>
<p><img src="github.png" alt=""></p>
<p>&emsp;&emsp;选这个SSH因为用HTTPS的话以后每次更新都要输入密码。之前上传SSH公钥就是为了用SSH。接下来依次在命令行输入下面的内容。</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">git remote add origin git@github.com:huiboxes/test.git	#可以在github复制然后在命令行粘贴</span><br><span class="line">git push -u origin master</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;刷新Github你会发现你的仓库上传上去了。</p>
<h6 id="3、将Github上的仓库克隆到本地"><a href="#3、将Github上的仓库克隆到本地" class="headerlink" title="3、将Github上的仓库克隆到本地"></a>3、将Github上的仓库克隆到本地</h6><p>&emsp;&emsp;找到一个觉得不错的开源仓库或者自己创建个新仓库，打开仓库首页单击<code>Clone or download</code>复制SSH地址，进入一个你想作为存放工作区的文件夹输入</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">git clone 粘贴刚刚复制的地址</span><br></pre></td></tr></table></figure>

<p>&emsp;&emsp;运行完后会发现文件夹内多出一个与你github上仓库同名的文件夹。将工作区内的变更(增加、删除、改动都是变更)上传到Github的话，只需加上<code>git pull</code> 与<code>git push</code>。完整流程如下：</p>
<p>&emsp;&emsp;<strong>git add  → git commit → git pull  → git push</strong></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/git/" rel="tag"># git</a>
          
            <a href="/tags/%E5%AE%9E%E7%94%A8%E7%BD%91%E7%AB%99/" rel="tag"># 实用网站</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/12/20/floatAndposition/" rel="next" title="浮动与定位">
                <i class="fa fa-chevron-left"></i> 浮动与定位
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/01/16/flex/" rel="prev" title="flex布局">
                flex布局 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/tx.png"
                alt="Shaohui" />
            
              <p class="site-author-name" itemprop="name">Shaohui</p>
              <p class="site-description motion-element" itemprop="description">记录学习生活</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/%7C%7C%20archive">
              
                  <span class="site-state-item-count">16</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">8</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">30</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。"><span class="nav-number">1.</span> <span class="nav-text">声明：本文以实际使用的角度出发，因为短时间内是不太好理解的，使用一定时间后自然就理解了，刚开始比较无趣，只有背命令。纸上得来终觉浅，绝知此事要躬行。</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#Github是什么？"><span class="nav-number">1.1.</span> <span class="nav-text">Github是什么？</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#Git是什么？工作流程是什么？"><span class="nav-number">1.2.</span> <span class="nav-text">Git是什么？工作流程是什么？</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#一、准备工作"><span class="nav-number">1.3.</span> <span class="nav-text">一、准备工作</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#二、配置Git-Bash："><span class="nav-number">1.4.</span> <span class="nav-text">二、配置Git Bash：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#三、配置Github"><span class="nav-number">1.5.</span> <span class="nav-text">三、配置Github</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#1、获取SSH公钥"><span class="nav-number">1.5.1.</span> <span class="nav-text">1、获取SSH公钥</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#2、在Github添加公钥"><span class="nav-number">1.5.2.</span> <span class="nav-text">2、在Github添加公钥</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#3、测试是否已对接"><span class="nav-number">1.5.3.</span> <span class="nav-text">3、测试是否已对接</span></a></li></ol></li><li class="nav-item nav-level-5"><a class="nav-link" href="#四、使用Git"><span class="nav-number">1.6.</span> <span class="nav-text">四、使用Git</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#1、本地仓库的使用-跟着敲会有奇效"><span class="nav-number">1.6.1.</span> <span class="nav-text">1、本地仓库的使用(跟着敲会有奇效)</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#2、将本地仓库上传到Github"><span class="nav-number">1.6.2.</span> <span class="nav-text">2、将本地仓库上传到Github</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#3、将Github上的仓库克隆到本地"><span class="nav-number">1.6.3.</span> <span class="nav-text">3、将Github上的仓库克隆到本地</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Shaohui</span>

  
</div>









        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: '3Q9JSwomPnFzEL7XsxUM57gR-gzGzoHsz',
        appKey: 'TTCatE57NFJMvykyoop9lY5i',
        placeholder: '留下宝贵意见',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

</body>
</html>
